package sevensoft.行为型模式.解释器模式;

public class Demo {
    public static void main(String[] args) {
        Context context = new Context();

        Variable a = new Variable("a");
        Variable b = new Variable("b");
        Variable c = new Variable("c");

        context.assign(a, 2);
        context.assign(b, 3);
        context.assign(c, 1);

        AbstractExpression abstractExpression = new Plus(a, new Minus(b, c));

        int res = abstractExpression.interpret(context);

        System.out.println(abstractExpression + "=");
        System.out.println(res);
    }
}
